package com.beetlestech.nfe.main.biz.com.impl;
import com.beetlestech.nfe.fw.core.biz.AbstractDBLogic;
import com.beetlestech.nfe.main.biz.com.HbActiveEmail;
import com.beetlestech.nfe.main.biz.com.dto.EmailactiveInfoDTO;
import com.beetlestech.nfe.main.biz.constant.CommonConstant;
import com.beetlestech.nfe.main.biz.constant.CtgCodeConstant;
import com.beetlestech.nfe.main.biz.constant.HbMessageCode;
import com.beetlestech.nfe.main.db.constant.SQLConstant;
import com.beetlestech.nfe.main.db.tbl.EmailactiveDTO;
import com.beetlestech.nfe.main.db.tbl.MstusrDTO;

public class HbActiveEmailImpl extends AbstractDBLogic implements HbActiveEmail, CtgCodeConstant, HbMessageCode, CommonConstant, SQLConstant {

	@Override
	public EmailactiveInfoDTO checkUserActiveCode(String activeCode) {

		EmailactiveDTO  emailactiveDTO=new EmailactiveDTO();
		EmailactiveInfoDTO emailactiveInfoDTO=new EmailactiveInfoDTO();
		MstusrDTO mstusrDTO=new MstusrDTO();
		emailactiveDTO.setactiveCode(activeCode);
		if(queryDAO.count(EmailactiveDTO.COUNT, emailactiveDTO)>0){
			//queryDAO.queryForObject(EmailactiveDTO.EQUAL_SEARCH);
			EmailactiveDTO emailactiveDTOTwo=queryDAO.queryForObject(EmailactiveDTO.EQUAL_SEARCH, emailactiveDTO);
			
			emailactiveInfoDTO.setuserid(emailactiveDTOTwo.getuserid());
			mstusrDTO.setusrid(emailactiveDTOTwo.getuserid());
			mstusrDTO.setstate(1);
			updateDAO.update(MstusrDTO.UPDATE, mstusrDTO);
			
		}
		else{
			createApplicationException(M10080WC);
		}
		return emailactiveInfoDTO;
	}

}
